<?php

	# PAGE SETTING
	 $class_nam   ='';
	 $add_function   ='';
	//$class_name   = 'serviceClass';
	//$add_function = 'addNewservice'; 
	class serviceClass
	{
		private $myFields=array("id","name","description","type","terms","link","status","price");
		
		function addNewservice($tblname,$meminfo)
		{
			global $wpdb;
			$count = sizeof($meminfo);
			if($count>0)
			{
				$id=0;
				$field="";
				$vals="";
				foreach($this->myFields as $key)
				{
					if($field=="")
					{
						$field="`".$key."`";
						$vals="'".$meminfo[$key]."'";
					}
					else
					{
						$field=$field.",`".$key."`";
						$vals=$vals.",'".$meminfo[$key]."'";
					}
				}
				// PROFILE PICTURE
				//$field=$field.",`image`";
				//$vals=$vals.",'".$profile_picture."'";

				 $sSQL = "INSERT INTO ".$tblname." ($field) values ($vals)";
			
				
				$wpdb->query($sSQL);
				return true;
			}
			else
			{
				return false;
			}
		}

		function updservice($tblname,$meminfo,$profile_picture='')
		{
			global $wpdb;
		 	$count = sizeof($meminfo);
		
			if($count>0)
			{
				$field="";
				$vals="";
				foreach($this->myFields as $key)
				{
					if($field=="" && $key!="id")
					{
						$field="`".$key."` = '".$meminfo[$key]."'";
					}
					else if($key!="id")
					{
						$field=$field.",`".$key."` = '".$meminfo[$key]."'";
					}
				}
				// PROFILE PICTURE
				if($profile_picture!=''){
					
					$field=$field.",`image` = '".$profile_picture."'";
					
		
				}
				
				$sSQL = "update ".$tblname." set $field where id=".$meminfo["id"];
				
				
				$wpdb->query($sSQL);
				return true;
			}
			else
			{
				return false;
			}
		}
	}


?>